package com.example.androidtraining_ahut2020;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import android.util.Log;
import android.widget.TextView;

import java.util.Date;

public class MainActivityDay08ShowTime extends AppCompatActivity {
    TextView textView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_day08_show_time);

        textView = super.findViewById(R.id.textView);
        new Thread(new RefreshThread()).start();

        //数据的获取和解析
        Bundle bundle = getIntent().getExtras();
        Log.e("IntentDemo", bundle.getString("school"));//pass String
        Log.e("IntentDemo", Integer.toString(bundle.getInt("year")));//pass Integer
    }

    class RefreshThread implements Runnable {
        RefreshThread() {

        }

        @Override
        public void run() {
            try {
                while (true) {
                    textView.setText(new Date().toLocaleString());
                    Thread.sleep(1000);
                }
            } catch (InterruptedException exp) {

            }
        }
    }
}